import { mapMutations } from 'vuex'
import { Toast } from 'vant';
export default {
    methods: {
        _addCart (item) {
            const { items } = this.$store.state.cart
            const index = items.findIndex(el => el.id === item.id)
            if (index === -1) {
              this.add_cart(item)
              Toast('加入购物车成功，请前往结算')
            } else {
               Toast('购物车已有该商品，请前往结算')
            }
        },
        ...mapMutations('cart', ['add_cart'])
    }
}